package com.yueka.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yueka.pojo.entity.course.CourseRecord;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

public interface CourseRecordMapper extends BaseMapper<CourseRecord> {

    void update(CourseRecord recordRecord);

    @Delete("delete from course_record where course_id = #{courseId}")
    void delete(Integer courseId);

    Page<CourseRecord> getList(@Param("page") Page<CourseRecord> page, @Param("schoolTime") String schoolTime, @Param("status") String status);

    Page<CourseRecord> getByStudentId(@Param("page") Page<CourseRecord> page, @Param("studentId") Integer studentId, @Param("start") LocalDateTime start, @Param("end") LocalDateTime end, @Param("crType") String crType);

    Page<CourseRecord> getByTeacherId(@Param("page") Page<CourseRecord> page, @Param("teacherId") Integer teacherId, @Param("start") LocalDateTime start, @Param("end") LocalDateTime end);

    @Delete("delete from course_record where id = #{id}")
    void deleteById(Integer id);

    @Select("select cr.id as id, cr_type, teacher_id, cr.status as status, content, job, school_time, remark, course_id, teacher_name from course_record cr, teacher t where cr.teacher_id = t.id and course_id = #{courseId}")
    List<CourseRecord> selectByCourseId(Integer courseId);
}
